# -*- coding: utf-8 -*-
# This code written by ChanGOGOGO
"""
更新任务信息：可修改外呼线路数，开启/暂停/结束任务
"""
import sys
import os

current_script_dir = os.path.dirname(os.path.abspath(__file__))
parent_dir = os.path.dirname(current_script_dir)
if parent_dir not in sys.path:
    sys.path.append(parent_dir)
from callplus_api import OpenAPI

if __name__ == "__main__":
    api = OpenAPI(env="aibpo")
    end_task_id = 139567
    total_task_num = 13000
    start_task_id = end_task_id - total_task_num
    for task_id in range(start_task_id, end_task_id + 1):
        # 手动查询数据库任务，批量结束
        # with open("/Users/changogogo/Downloads/task_id.txt") as f:
        #     content = f.readlines()
        # task_ids = [int(task_id.strip()) for task_id in content]
        # for task_id in task_ids:
        api.update_task(
            inner_task_id=task_id,
            # out_task_id="",
            # callout_line_num=3,
            # task_status="startTask",  # 任务状态. 可选值：startTask-开启任务；pauseTask-暂停任务；finishTask-停止任务。
            # task_status="pauseTask",  # 任务状态. 可选值：startTask-开启任务；pauseTask-暂停任务；finishTask-停止任务。
            task_status="finishTask",  # 任务状态. 可选值：startTask-开启任务；pauseTask-暂停任务；finishTask-停止任务。
        )
    print("✅ 全部任务更新结束！")
